/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import Persistence.UserFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
import servidorped.User;

/**
 *
 * @author Micosil
 */
public class admindeleteuser implements Command{

    @Override
    public boolean execute(String[] stringlist, User user) {
        if (UserFactory.getUserPersistence().deleteUser(stringlist[1])){
            user.getUserSender().setToSend("User no longer exists.");
            Logger.getGlobal().log(Level.INFO, "Admin {0} deleted user {1}", new Object[]{user.getUserName(), stringlist[1]});
        }        
        else{
            user.getUserSender().setToSend("Could not delete user.");
            Logger.getGlobal().log(Level.INFO, "Admin {0} failed to delete user {1}", new Object[]{user.getUserName(), stringlist[1]});
        }
        return true;
    }
    
}
